#ifndef RWeakReference_H
#define RWeakReference_H

#include <Typedef.h>
#include <Defines.h>
#include <CSharpGarbagePointer.h>
#include <CSharpPropertyMethods.h>

#include <System/Runtime/Serialization/SerializationInfo.h>
#include <System/Runtime/Serialization/StreamingContext.h>

#include "Object.h"
	
namespace Riccsson
{
	namespace System
	{
		// Summary:
		//     Represents a weak reference, which references an object while still allowing
		//     that object to be reclaimed by garbage collection.
		class WeakReference// : ISerializable
		{
			PROP3(WeakReference, bool, IsAlive)
			PROP3(WeakReference, GC_PTR<object>, Target)
			PROP3(WeakReference, bool, TrackResurrection)

			COPY_CONSTRUCTOR(WeakReference)
			{
				PROP3_INIT_COPY(WeakReference, bool, IsAlive);
				PROP3_INIT_COPY(WeakReference, GC_PTR<object>, Target);
				PROP3_INIT_COPY(WeakReference, bool, TrackResurrection);
			}

			// Summary:
			//     Initializes a new instance of the System.WeakReference class, referencing
			//     the specified object.
			//
			// Parameters:
			//   target:
			//     The object to track or null.
			public: WeakReference(GC_PTR<object> target)
				: PROP3_INIT(WeakReference, IsAlive)
				, PROP3_INIT(WeakReference, Target)
				, PROP3_INIT(WeakReference, TrackResurrection)
			{

			}
			
			//
			// Summary:
			//     Initializes a new instance of the System.WeakReference class, referencing
			//     the specified object and using the specified resurrection tracking.
			//
			// Parameters:
			//   target:
			//     An object to track.
			//
			//   trackResurrection:
			//     Indicates when to stop tracking the object. If true, the object is tracked
			//     after finalization; if false, the object is only tracked until finalization.
			public: WeakReference(GC_PTR<object> target, bool trackResurrection)
				: PROP3_INIT(WeakReference, IsAlive)
				, PROP3_INIT(WeakReference, Target)
				, PROP3_INIT(WeakReference, TrackResurrection)
			{
				throw;
			}
			//
			// Summary:
			//     Initializes a new instance of the System.WeakReference class, using deserialized
			//     data from the specified serialization and stream objects.
			//
			// Parameters:
			//   info:
			//     An object that holds all the data needed to serialize or deserialize the
			//     current System.WeakReference object.
			//
			//   context:
			//     (Reserved) Describes the source and destination of the serialized stream
			//     specified by info.
			//
			// Exceptions:
			//   System.ArgumentNullException:
			//     info is null.
			protected: WeakReference(SerializationInfo* info, StreamingContext* context)
				: PROP3_INIT(WeakReference, IsAlive)
				, PROP3_INIT(WeakReference, Target)
				, PROP3_INIT(WeakReference, TrackResurrection)
			{
				throw;
			}

			// Summary:
			//     Gets an indication whether the object referenced by the current System.WeakReference
			//     object has been garbage collected.
			//
			// Returns:
			//     true if the object referenced by the current System.WeakReference object
			//     has not been garbage collected and is still accessible; otherwise, false.
			public: virtual PROP3_GET(bool, IsAlive)
			{
				throw;
			}
			private: virtual PROP3_SET(bool, IsAlive){throw;}

			//
			// Summary:
			//     Gets or sets the object (the target) referenced by the current System.WeakReference
			//     object.
			//
			// Returns:
			//     null if the object referenced by the current System.WeakReference object
			//     has been garbage collected; otherwise, a reference to the object referenced
			//     by the current System.WeakReference object.
			//
			// Exceptions:
			//   System.InvalidOperationException:
			//     The reference to the target object is invalid. This exception can be thrown
			//     while setting this property if the value is a null reference or if the object
			//     has been finalized during the set operation.
			//public: virtual GC_PTR<object> Target { get; set; }
			public: virtual PROP3_GET(GC_PTR<object>, Target)
			{
				throw;
			}
			public: virtual PROP3_SET(GC_PTR<object>, Target)
			{
				throw;
			}
			
			//
			// Summary:
			//     Gets an indication whether the object referenced by the current System.WeakReference
			//     object is tracked after it is finalized.
			//
			// Returns:
			//     true if the object the current System.WeakReference object refers to is tracked
			//     after finalization; or false if the object is only tracked until finalization.
			//public: virtual bool TrackResurrection { get; }
			public: virtual PROP3_GET(bool, TrackResurrection)
			{
				throw;
			}
			private: virtual PROP3_SET(bool, TrackResurrection){throw;}

			// Summary:
			//     Populates a System.Runtime.Serialization.SerializationInfo object with all
			//     the data needed to serialize the current System.WeakReference object.
			//
			// Parameters:
			//   info:
			//     An object that holds all the data needed to serialize or deserialize the
			//     current System.WeakReference object.
			//
			//   context:
			//     (Reserved) The location where serialized data is stored and retrieved.
			//
			// Exceptions:
			//   System.ArgumentNullException:
			//     info is null.
			//[SecurityCritical]
			public: virtual void GetObjectData(SerializationInfo* info, StreamingContext* context)
			{
				throw;
			}
		};
	}
}

#endif